<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/base.php.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="images/favicon.ico" type="image-x-icon"  />
<!-- InstanceBeginEditable name="doctitle" -->
<title>CineBD - A divers&atilde;o espera voc&ecirc;</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="cinebd.js"></script>
<style type="text/css">

	body {
		
		/*background-color:#80CFD8;*/
		background-color:#FFFFFF;
		/*background-image:url(../images/bg_thin.png);
		background-repeat:repeat-x;*/
		font-family:"Courier New", Courier, monospace;
		top:0px;
		margin-top:0px;
		padding:0px;
	} 
	
	a {
		
		text-decoration:none;
		color:#000;
	}
	
	.menu {
		
		color:#000000;
		text-align:center;
		font-size:18px;
		font-family:"Courier New", Courier, monospace;
		//border-bottom: 1px solid #03C ;
	}
	
	.menu:hover {
		
		border: 2px solid #FFF;
		//border-left: 5px solid #FFF;
		//border-bottom: 5px solid #FFF;
		//border-right: 10px solid #fff;
		//background-color: #06F;
	}
	
	.logo {
		width:150px;
		height:150px;
	}
	
	.header {
		background-image:url(images/Template_03.png);
		//background-repeat:repeat-x;
		width:300px;
		height:149px;
		text-align:center;
	}
	
	.sub_header {
		
		background-image:url(images/sub_header.png);
		width:681px;
		height:100px;
		text-align:center;
		font-size:18px;
		font-weight:bold;
		font-family:"Courier New", Courier, monospace;
		
	}
	
	.logout {
		
		font-size:14px;
		color:#FFF;
		
	}
	
	.logout:hover {
		
		border-bottom: 2px solid #FFF;
		
	}
	
	.left_menu {
		
		background-image:url(images/bg_thin.png);
		background-attachment:fixed;
		width:356px;
		height:768px;
		vertical-align:top;
		text-align:center;
	}
	
	.right_menu {
		
		background-image:url(images/bg_thin.png);
		background-attachment:fixed;
		width:355px;
		height:768px;
		vertical-align:top;
		font-size:15px;
		font-family:"Courier New", Courier, monospace;
		text-align:center;
	}
	
	.right_menu_text {
		
		text-align:center;
		font-size:16px;
	}
	
	.right_menu_text:hover {
		
		border-bottom: 2px solid #FFF;
	}
	
	.bottom_bg {
		background-image:url(images/bottom_bg.png);
		background-repeat:y;
	}
	
	.proximas {
		text-align:center;
		font-weight:bold;
		font-size:18px;
	}
	

	.content {
		
		text-align:center;
		vertical-align:text-top;
		font-size:12px;
		font-family:"Courier New", Courier, monospace;
		width:auto;
	}
	
	.linhaSessao {
		background-color:#FF9;
		font-weight:bold;
		text-align:center;
			
	}
	
	.colunaDias {
		background-color:#FF9;	
		font-weight:bold;
	}
	
	.centroTabela {
		background-color:#CC3333;
		color:#FFF;
		font-weight:bold;
	}
	
	.colunaIngressos {
		background-color:#FF9;	
		font-weight:bold;
	}
	
	.centroIngressos {
		font-weight:bold;
		text-align:center;
		
	}

	.ingressosBaratos {
		color:#090;
		font-weight:bold;
		text-align:center;
		
	}
	
	.menu_admin {
		background-image:url(images/square.png);
		background-repeat:no-repeat;
		background-position:left;
		width:10px;
		height:10px;
		
	}
	
	
	
	<!-- TemplateBeginEditable name="css" -->
	
	<!-- TemplateEndEditable -->
</style>
</head>

<body>
<table align="center" cellpadding="0" cellspacing="0" border="0" style="top:0px;margin-top:0px;">
	<tr>
    	<td rowspan="3" class="left_menu">
        	<a href="index.php">
            	<img class="logo" src="images/logo.png" />
            </a>
            <br /> 
            
            <table width="100%" cellpadding="0" cellspacing="8" align="center">
            	<tr>
                	<td>
                    	<span class="menu"><a href="emcartaz.php">&nbsp;EM CARTAZ&nbsp;</a></span>
                    </td>
                 </tr>
                 <tr>
                	<td>
                    	<span class="menu"><a href="quemsomos.php">&nbsp;QUEM SOMOS&nbsp;</a></span>
                    </td>
                 </tr>
                 <tr>
                	<td>
                    	<span class="menu"><a href="faleconosco.php">&nbsp;FALE CONOSCO&nbsp;</a></span>
                    </td>
                 </tr>
                 <tr>
                	<td>
                    	<span class="menu"><a href="ingressos.php">&nbsp;INGRESSOS&nbsp;</a></span>
                    </td>
                 </tr>
                 <tr>
                	<td>
                    	<span class="menu"><a href="#" id="clientes">&nbsp;CLIENTES&nbsp;</a></span>
                        <br />
                        <div id="menu_client" style="text-align:left; font-size:15px; display:none; margin-left:25%;">
                        	<ol style="list-style-type:none;">
                            	<li><a href="login.php">Logar</a></li>
                                <li><a href="cadastro.php">Cadastrar</a></li>                    
                            </ol>
                        </div>
                    </td>
                 </tr>
            </table> 
  		</td>
        <td class="header">
        	<img src="images/header.png" />
        </td>
                
        <td rowspan="3" class="right_menu">
          	<img class="logo" src="images/popcorn.png" style="margin-left:10px"/>
        	<table width="100%" cellpadding="0" cellspacing="8">
            	<tr>
                	<td class="proximas">
                    	PR&Oacute;XIMAS ESTREIAS
                    </td>
                    </tr>
                    <br />
                    <tr>
                    <td>
         
		<?php
				require_once("php/config.php");
				require_once("php/postgres.php");
				
				try {
					
					$confs = $GLOBALS["CONFIGS"]["PSQL_DB"];
					$pgcon = new PostgresConnection($confs["HOST"], $confs["PORT"], $confs["USER"], $confs["PASSWORD"], $confs["DATABASE"]);
            
					$estreias = $pgcon->getAllEstreias();					

                    echo" <table width='100%' cellpadding='0' cellspacing='8' align='center'>";
                        foreach ($estreias as $estreia) {
                    		$nome = $estreia["nome"];
                            echo "<tr>
                                <td>
                                    <span class='right_menu_text'><a href='#' onclick=\"javascript:opensinopse('$nome');\">&nbsp;" . $nome .  "&nbsp;</a></span>
                                </td>
                            </tr>";
             			}
        			echo "</table>					
            </td>
            </tr>          
            </table>
        </td>
    </tr>";    
   
            if (isset($_COOKIE["checkLogin"])){
            
             	echo" <td class='sub_header'>Ol&aacute;, $_COOKIE[checkLogin]!
                <span class='logout'><a href='logout.php'>Sair</a></span></td></tr>";
                
            } else {
            
            	echo' <td class="sub_header"></td>';
            }
        
 		} catch (PostgresConnectionException $pce) {
            
        echo "<span style='color:red;'>Desculpa, mas sua requisi&ccedil;&atilde;o n&atilde;o pode ser processada agora. Volte mais tarde.</span>";
        }
                    
?>
        
    
    <tr>
    	<td class="content">
        	<!-- InstanceBeginEditable name="content" -->
            <script type="text/javascript">
			
				function triggerLink() {
					
					$("#ver_link").removeAttr("href");
					$("#ver_link").unbind('click');
					$("#ver_link").html("Verificando...");
					
					if ($("#email").val() == "") {
					
						alert("E-mail inválido");
						$("#ver_link").css("color", "red");
						$("#ver_link").removeData("ok");
					    $("#ver_link").html("Verificar");
						$("#ver_link").attr("href", "#");
						$("#ver_link").click(triggerLink);
						return;
					}
					
					$.get("verify.php",
						   {
							  type : "1",
							  value : $("#email").val()
						   },
						   function(data) {
							   
							   if (data != 0) {
								
									$("#ver_link").css("color", "green");
									$("#ver_link").data("ok", true);
							   } else {
								   
								   $("#ver_link").css("color", "red");
								   $("#ver_link").removeData("ok");
								   alert("Seu e-mail já consta em nosso banco de dados");
							   }
							   
							    $("#ver_link").html("Verificar");
								$("#ver_link").attr("href", "#");
								$("#ver_link").click(triggerLink);
						   });
				}
				
				function triggerLogin() {
					
					$("#ver_login").removeAttr("href");
					$("#ver_login").unbind('click');
					$("#ver_login").html("Verificando...");
					
					if ($("#login").val() == "")  {
						
						$("#ver_login").attr("href", "#");
						$("#ver_login").click(triggerLogin);
						$("#ver_login").html("Verificar");
						$("#ver_login").css("color", "red");
						$("#ver_login").removeData("ok");
						alert("Login inválido");
						return;
					}
					
					$.get("verify.php",
						   {
							  type : "2",
							  value : $("#login").val()
						   },
						   function(data) {
							   
							   if (data != "0") {
								
									$("#ver_login").css("color", "green");
									$("#ver_login").data("ok", true);
							   } else {
								   
								   $("#ver_login").css("color", "red");
								   $("#ver_login").removeData("ok");
								   alert("Esse login já consta em nosso banco de dados");
							   }
							   
								$("#ver_login").attr("href", "#");
								$("#ver_login").click(triggerLogin);
								$("#ver_login").html("Verificar");
						   });
				}
				
				function sendForm() {
				
					$("#send_cadas").attr("disabled", "disabled");
					$("#send_cadas").val("Enviando...");
					
					var error = false;
					var msg = "";
					var mail = $("#email").val();
					var mail_regex = /^([0-9a-zA-Z]+([_.-]?[0-9a-zA-Z]+)*@[0-9a-zA-Z]+[0-9,a-z,A-Z,.,-]*(.){1}[a-zA-Z]{2,4})+$/
					$("#email").css("background-color", "white");
					if (!mail_regex.exec(mail)) {
						
						$("#email").css("background-color", "red");
					}
					
					var p1 = $("#pass").val();
					var p2 = $("#pass2").val();
					
					$("#pass").css("background-color", "white");
					if (p1 == "" || p1 != p2) {
					
						error = true;
						$("#pass").css("background-color", "red");
					}
					
					var mand_field = [
										"name",
										"sob_name",
										"cart",
										"tit_cart",
									 ];
									 
					var values = [];
					
					for (field in mand_field) {
					
						var key = mand_field[field];
						values[key] = $("#" + key).val();
						$("#" + key).css("background-color", "white");
						if (values[key] == "") {
							
							error = true;
							$("#" + key).css("background-color", "red");
						}
					}
					
					if(!($("#ver_link").data("ok")) || !($("#ver_login").data("ok"))) {
						
						msg += "\nClique para verificar seu e-mail e login";
						error = true;
					}
					
					if (!error) {
						
						$.post("addcadas.php",
								  {
									  name : values["name"],
									  sob_name : values["sob_name"],
									  ender : $("#ender").val(),
									  email : mail,
									  login : $("#login").val(),
									  pass : p1,
									  cart : $("#cart").val(),
									  tit_cart : $("#tit_cart").val()
								  },
								  function(data) {
									  
									  if (data != 0) {
										
											alert("Houve um erro na realização do seu cadastro.\n" + data);
									  } else {
										
											alert("Cadastro realizado com sucesso");
											//$("#cadasform").reset();
											document.forms[0].reset();
											$("#res_pass").html("");
											$("#ver_link").removeData("ok");
											$("#ver_link").css("color", "#00F");
											$("#ver_login").removeData("ok");
											$("#ver_login").css("color", "#00F");
									  }
									  
									  $("#send_cadas").removeAttr("disabled");
									  $("#send_cadas").val("Cadastrar");
								  });
					} else {
					
						msg += "Verifique os campos em vermelhos";
					}
					
					if (msg != "") {
					
						alert(msg);
					}
					
					$("#send_cadas").removeAttr("disabled");
					$("#send_cadas").val("Cadastrar");
				}
				
				function triggerKey(e) {
				
					var valp1 = $("#pass").val();
					var valp2 = $("#pass2").val();
					if (valp1 != "" && valp2 != "") {
					
						if (valp1 != valp2) {
						
							$("#res_pass").html("As senhas n&atilde;o s&atilde;o iguais.");
						} else {
							
							$("#res_pass").text("Senhas iguais");
						}
					} else {
					
						$("#res_pass").text("");
					}
				}
				
				$(document).ready(function() {
										   
										   	$("#ver_link").click(triggerLink);
											$("#ver_login").click(triggerLogin);
											$("#send_cadas").click(sendForm);
											$("#pass").keyup(triggerKey);
											$("#pass2").keyup(triggerKey);
											$("#ver_login").data("ok", false);
											$("#ver_link").data("ok", false);
											$("#login").keyup(function() {
																	   
																$("#ver_login").removeData("ok");
																$("#ver_login").css("color", "#00F");
															 });
											$("#email").keyup(function() {
																	  
																$("#ver_link").removeData("ok");
																$("#ver_link").css("color", "#00F");
															 });
										   });
			</script>
			<br />
            
            <div style="text-align:left; margin-left:40px;">
            <span class="proximas">CADASTRO</span>
            <br />
            <br />
            <form id="cadasform" action="#" onsubmit="return false;">
            	<table cellpadding="0" cellspacing="0" border="0">
                	<tr>
            			<td><span>Nome: &nbsp;&nbsp;</span></td>
                        <td><input id="name" name="name" type="text" size="53" maxlength="50" /></td>
                    </tr>
                    <tr>
                		<td><span>Sobrenome: &nbsp;&nbsp; </span></td>
                        <td><input id="sob_name" name="sob_name" type="text" size="53" maxlength="100" /></td>
                    </tr>
                    
                		<td><span>Endere&ccedil;o: &nbsp;&nbsp; </span></td>
                        <td><input id="ender" name="ender" type="text" size="53" maxlength="100" /></td>
                    </tr>
                     <tr>
                    	<td><span>E-mail: &nbsp;&nbsp;</span></td>
                        <td><input id="email" name="email" type="text" size="53" maxlength="50" /><span id="ver_email">&nbsp;<a href="#" id="ver_link" style="color:#00F">Verificar</a></span></td>
                     </tr>
                </table>

                <table cellpadding="0" cellspacing="0" border="0">
                	<tr>
                    <td><span>N&uacute;mero do cart&atilde;o de cr&eacute;dito: &nbsp;&nbsp;</span></td>
                        <td><input name="cart" id="cart" type="text" size="32" maxlength="50" /></td>
                         </tr>
                         <tr>
                       	<td><span>Nome do titular do cart&atilde;o: &nbsp;&nbsp;</span></td>
                        <td><input name="tit_cart" id="tit_cart" type="text" size="32" maxlength="50" /></td> 
                </table>
                
                <table cellpadding="0" cellspacing="0" border="0">
                	<tr>
                        <td>
                            <span>Telefone: &nbsp; <input id="tel" name="tel" type="text" size="15" maxlength="10" /></span>
                        </td>
                    	<td><span>&nbsp;&nbsp;&nbsp; Celular: &nbsp;</span> <input id="cel" name="cel" type="text" size="15" maxlength="10" /></td>
                    </tr>
                </table>
                <table cellpadding="0" cellspacing="0" border="0">
                	<tr>
                    <td><span>Login: &nbsp;&nbsp;</span></td>
                        <td><input name="login" id="login" type="text" size="30" maxlength="20" />&nbsp;<a href="#" id="ver_login" style="color:#00F">Verificar</a></span></td>
                         </tr>
                         <tr>
                       	<td><span>Senha: &nbsp;&nbsp;</span></td>
                        <td><input name="pass" id="pass" type="password" size="30" maxlength="10" /></td> 
                    </tr>
                         <tr>
                       	<td><span>Confirmar senha: &nbsp;&nbsp;</span></td>
                        <td><input id="pass2" type="password" size="30" maxlength="10" />&nbsp;<span id="res_pass"></span></td> 
                    </tr>
                </table>
                <br  />                
                <input type="button" id="send_cadas" value="Cadastrar" />
            </form>
            </div>
			<!-- InstanceEndEditable -->
    </tr>    
</table>
</body>
<!-- InstanceEnd --></html>
